//友好时间格式
Date.prototype.friendTime = function () {
    let gmtCreate = this  //时间搓
    let presentTime = new Date().getTime()  //获取当前时间搓
    let diffTime = (presentTime - gmtCreate) / 1000 //时间戳之差
    let time = ''  //接收时间
    let data = new Date(gmtCreate)
    if (diffTime < 30) {
        time = "刚刚"
    } else if (diffTime < 3600) {  //显示分钟
        let minum = Math.ceil(diffTime / 60)
        minum = minum == 60 ? 59 : minum  //三元判断
        time = minum + '分钟之前'
    } else if (diffTime < 3600 * 24) {  // 小于一天
        time = parseInt(diffTime / 60 / 60) + '小时之前'
    } else if (diffTime < 3600 * 48) {  //显示天数
        time = parseInt(diffTime / 60 / 60 / 24) + '天前'
    } else {  //其余时间 年月日
        time = data.toLocaleDateString().replace('/', "年").replace('/', '月') + '日' + data
            .toTimeString().replace(':', '时').substring(0, 5) + '分'
    }
    return gmtCreate = time
}

// 登录时间
Date.prototype.logTime = function () {
    let data = this //时间搓
    let month = data.getMonth() + 1  //月
    let dsy = data.getDate()  //天
    let getHours = data.getHours()  //时
    let minute = data.getMinutes()  //分
    return month + '月' + dsy + '日' + getHours + '时' + minute + '分'
}

// 生日
Date.prototype.birthday = function () {
    let data = this //时间搓
    let year = data.getFullYear()
    let month = data.getMonth() + 1  //月
    let dsy = data.getDate()  //天
    return year + '年' + month + '月' + dsy + '日'
}

//开始时间
Date.prototype.startTime = function () {
    let data = this //时间搓
    let year = data.getFullYear()
    let month = data.getMonth() + 1 < 10 ? '0' + (data.getMonth() + 1) : data.getMonth() + 1  //月
    let dsy = data.getDate() < 10 ? '0' + data.getDate() : data.getDate()  //天
    let getHours = data.getHours() < 10 ? '0' + data.getHours() : data.getHours()  //时
    return year + '-' + month + '-' + dsy + ' ' + getHours + ':' + data.toTimeString().substring(0, 5)
} 